Asset To Asset Association
Introduction
The Assetic Cloud Platform supports direct association of an asset to another asset.
An asset may be associated to more than one asset. Refer to the Assetic Knowledge Base article Asset Associations for additional details.
The following Asset Association API's are available:
- GET /api/v2/assets/{id}/associations
- Get a collection of associations of a particular asset
- PUT /api/v2/assets/{id}/associations
- Create an association between 2 assets
- DELETE /api/v2/assets/{id}/associations/{toId}
- Remove association between 2 assets
This article will refer to a 'target' asset. This is the asset for which the associations are being determined.
Association Type - "Relation"
The property "Relation" is used by the Asset Association API's to describe the relationship of the asset to the associated assets.
The following relationship definitions may be applied/returned via the Association API's:
-
'Relates To', 'Obstructs', 'Is Obstructed By', 'Is Split From', 'Is Split To', 'Is Child Of', 'Is Parent Of', 'Merged Into', 'Merged From', 'Cloned To', 'Cloned From'
-
Descriptions of these relationships are provided in the Assetic Knowledge Base article Asset Associations.
Get Associations
The Assetic REST API GET /api/v2/assets/{id}/associations will get the assets associated to the given Assetic asset Id. The {id} must be the Assetic GUID identifier for the asset.
If the Assetic asset GUID is unknown it can be obtained from the Assetic REST Asset API GET /api/v2/assets/{id} or GET /api/v2/assets as described in the Assetic Knowledge Base article Retrieve Assets and associated records.
Since there may be more than one asset associated with the target asset, the response is a paginated collection of associations. The page size and page number may be used to get multiple pages of associations. If omitted, the default is page=1 and pageSize=20.
Sample Get Associations for Asset
The following example gets the assets associated with the asset GUID of "45f982ad-bb0d-e711-946c-06edd62954d7"
Sample Request
Request Method: GET
https://[your_site].assetic.net/api/v2/assets/45f982ad-bb0d-e711-946c-06edd62954d7/associations
Sample Response
Response Code: 200
The response includes page number and page size, with the total number of associations for the asset and total number of pages for the given page size. "ResourceList" is an array of associations.
{
"TotalResults": 1,
"TotalPages": 1,
"Page": 1,
"ResourceList": [
{
"Relation": "Is Split From",
"Id": "43d1c83b-7819-e511-9448-06edd62954d7",
"AssetId": "0008",
"AssetName": "Yera State School",
"_links": [],
"_embedded": null
}
]
}
Associate Asset to an Asset
The Assetic REST API PUT /api/v2/assets/{id}/associations creates an association between 2 assets.
The association requires a 'Relation' to indicate the relationship between the two assets.
Change Association Relationship
If the assets are already associated the 'Relation' may be changed by applying the PUT /api/v2/assets/{id}/associations again, but with the new relation. A second relation is not created.
Sample Association
The following example associates the asset with GUID 'a2834df4-6d19-4924-b0c9-0251d84fe118' (the target asset) to the asset with GUID '5d64335a-985b-e711-8187-025500ccdddb' (related asset).
The relationship is 'Relates To'
Sample Request
Request Method: PUT
https://[your_site].assetic.net/api/v2/assets/a2834df4-6d19-4924-b0c9-0251d84fe118/associations
Sample Request Payload
{
"Relation": "Relates To",
"Id": "5d64335a-985b-e711-8187-025500ccdddb"
}
Sample Response
Response Code: 200
{
"Relation": "Relates To",
"Id": "5d64335a-985b-e711-8187-025500ccdddb",
"AssetId": "Zen-4142",
"AssetName": "ANZ",
"_links": [],
"_embedded": null
}
Remove Asset Association
An asset association may be removed via the Assetic REST API DELETE /api/v2/assets/{id}/associations/{toId} where {id} is the asset GUID of target and {toId} is the asset GUID of the associated asset.
If there is no existing association the API will return a 500 error code. If successful the response code is 200. There is no response body.
Sample Association Removal
The following example removes the association from the target asset GUID 'a2834df4-6d19-4924-b0c9-0251d84fe118' of the asset GUID '5d64335a-985b-e711-8187-025500ccdddb'
Sample Request
Request Methods: DELETE
https://[your_site].assetic.net/api/v2/assets/a2834df4-6d19-4924-b0c9-0251d84fe118/associations/5d64335a-985b-e711-8187-025500ccdddb
Sample Response
Response Code: 200